'use strict';

import { actionTypes } from './actionTypes';

const initialState = {
	id: null,
	user_name: '',
	role: null,
};

function userAuth(state = initialState, action) {
	switch (action.type) {
		case actionTypes.SET_USER_AUTH:
			return {
				...state,
				...action.payload,
			};
		case actionTypes.LOGOUT:
		  return {
		  	...state,
		  	...{
		  		id: null,
		  		user_name: '',
		  		role: null,
		  	}
		  };
		default: 
			return state;
	}
}

export default userAuth;
